package com.boang.state;

/*
  @author: 13813
  @date: 2024/11/26 16:43
*/
public class Test02 {
    public static void main(String[] args) {
        /*ThreadStateWaitDemo02 demo02 = new ThreadStateWaitDemo02();

        Thread t0 = new Thread(demo02);
        t0.start();

        Thread t1 = new Thread(demo02);
        t1.start();*/

        /*Runnable runnable = new Runnable() {
            public void run() {
                while (true) {
                    System.out.println(Thread.currentThread().getName());
                }
            }
        };

        Thread t0 = new Thread(runnable);
        t0.start();

        Thread t1 = new Thread(runnable);
        t1.start();*/

        new Thread() {
            public void run() {
                while (true) {
                    try {
                        this.wait(); //等待
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                    System.out.println(Thread.currentThread().getName() + ":A");
                }
            }
        }.start();

        new Thread() {
            public void run() {
                while (true) {
                    try {
                        this.wait(); //等待
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                    System.out.println(Thread.currentThread().getName() + ":B");
                }
            }
        }.start();
    }
}
